import {
	$http
} from '@escook/request-miniprogram'
if (process.env.NODE_ENV === 'development') {
		$http.baseUrl='http://localhost:3000'
} else {
	   // $http.baseUrl='http://localhost:3000'
}

export const baseUrl='http://localhost:3000/'

export const getWechatInfo = (code) => $http.get(`/api/wxuser/getWechatInfo?code=${code}`)//获取openid和key
export const login = (data) => $http.post('/api/wxuser/login', data)
export const getUserInfo = (id) => $http.get(`/api/wxuser/${id}`)
export const editUserInfo = (id,data) => $http.post(`/api/wxuser/${id}`,data)

export const wechatTextCheck = (data) => $http.post(`/api/wechatCheck/text`,data)
export const wechatMediaCheck = (data) => $http.post(`/api/wechatCheck/media`,data)
//证书列表
export const getCertList = (data) => $http.get(`/api/certificates`,data)
//证书详情
export const getCertDetail = (id) => $http.get(`/api/certificates/${id}`)
//发布话题
export const sendTopic = (data) => $http.post(`/api/topics`,data)
//话题列表
export const getTopicList = (data) => $http.get(`/api/topics`,data)
// export const getMyTopic = (data) => $http.get(`/api/topics/user-topics`,data)
export const getTopicDetail= (topicId,data) => $http.get(`/api/topics/${topicId}`,data)
//发布评论
export const sendComment = (data) => $http.post(`/api/comments`,data)
export const getCommentList = (topicId) => $http.get(`/api/comments/${topicId}`)
export const getMyComment = (id) => $http.get(`/api/comments/myComment/${id}`)

//收藏
export const addFavorite = (data) => $http.post(`/api/favorite`,data)
export const delFavorite = (data) => $http.delete(`/api/favorite/user/${data.userId}/topic/${data.topicId}`,data)
export const getFavoriteList = (data) => $http.get(`/api/favorite/user/${data.userId}`,data)

//医生申请
export const applyDoctor = (userId,data) => $http.post(`/api/wxuser/${userId}/apply-doctor`,data)
export const getDoctorList = (data) => $http.get(`/api/doctor`,{status:'approved'})

//消息
export const sendMessage = (data) => $http.post(`/api/messages/send`,data)
export const getMessageList = (topicId) => $http.get(`/api/comments/${topicId}`)
